package com.lmc.chatroom.model;

import com.lmc.chatroom.constant.constant;
import lombok.Data;

@Data
public class Result {
    private Integer code;
    private String errmsg;
    private Object data;

    public static Result success(Object data) {
        Result result = new Result();
        result.code = constant.SUCCESS_CODE;
        result.data = data;
        return result;
    }

    public static Result fail(Object data, String errmsg) {
        Result result = fail(errmsg);
        result.data = data;
        return result;
    }

    public static Result fail(String errmsg) {
        Result result = new Result();
        result.code = constant.ERROR_CODE;
        result.errmsg = errmsg;
        return result;
    }

}
